1. Technical Field
The embodiments herein relates generally to task scheduling for Real-Time Operating Systems (RTOS), and more particularly, to a method and system for preemptive scheduling of tasks in an RTOS.
2. Description of Related Art
In computing technology, scheduling is a method by which threads, processes, or data flows are given access to system resources (e.g., processor time, communications bandwidth). The main target of scheduling is to load balance and share system resources effectively, thereby achieving a target quality of service. An efficient scheduling method is required for systems to perform multitasking and multiplexing effectively and efficiently.
A scheduler is an operating system module that selects the next jobs to be admitted into the system and that selects the next process to run. The scheduler can be categorized as preemptive scheduler or non-preemptive scheduler, based on whether the scheduler is capable of forcibly removing running processes from the CPU or resources, to allocate the CPU or resources to another process.
A preemptive scheduler determines priorities of ready processes/tasks in a system. For example, when a new task becomes ready, and if the priority of the new task is higher than that of the task currently being executed, then the current task is pre-empted, and the new task is given control. The preemptive scheduler is handled by a kernel of the RTOS.
The RTOS assigns a fixed priority rank to every process, and the scheduler arranges the processes in the ready queue in the order of their priority.
Typically, if the number of rankings is limited, then preemptive scheduling can be characterized as a collection of First-In First-Out (FIFO) queues, one for each priority ranking. The processes in lower-priority queues are selected only when all of the higher-priority queues are empty.